import type { FieldRule } from 'vant'

const mail: FieldRule[] = [
  { required: true, message: '请输入邮箱', trigger: 'onBlur' },
  {
    pattern: /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
    message: '邮箱格式错误',
    trigger: 'onBlur'
  }
]
const password: FieldRule[] = [
  { required: true, message: '请输入密码', trigger: 'onBlur' }
]

const name: FieldRule[] = [
  { required: true, message: '请输入用户名', trigger: 'onBlur' }
]

const productName: FieldRule[] = [
  { required: true, message: '请输入产品名称', trigger: 'onBlur' }
]

const oldPrice: FieldRule[] = [
  { required: true, message: '请输入原价', trigger: 'onBlur' }
]

const newPrice: FieldRule[] = [
  { required: true, message: '请输入现价', trigger: 'onBlur' }
]

const description: FieldRule[] = [
  { required: true, message: '请输入产品描述', trigger: 'onBlur' }
]

export const formRule = {
  mail,
  password,
  name,
  oldPrice,
  productName,
  newPrice,
  description
}
